

    \filetitle{bwf}{Butterworth filter with tunes}{tseries/bwf}

	\paragraph{Syntax}

Input arguments marked with a \texttt{\textasciitilde{}} (tilde) sign
may be omitted.

\begin{verbatim}
[T,C,CutOff,Lambda] = bwf(X,Order,~Range,...)
\end{verbatim}

\paragraph{Syntax with output arguments
swapped}

Input arguments marked with a \texttt{\textasciitilde{}} (tilde) sign
may be omitted.

\begin{verbatim}
[T,C,CutOff,Lambda] = bwf2(X,Order,~Range,...)
\end{verbatim}

\paragraph{Input arguments}

\begin{itemize}
\item
  \texttt{X} {[} tseries {]} - Input tseries object that will be
  filtered.
\item
  \texttt{Order} {[} numeric {]} - Order of the Butterworth filter;
  \texttt{Order=2} reproduces the Hodrick-Prescott filter
  \href{tseries/hpf}{\texttt{hpf}}, and \texttt{Order=1} reproduces the
  local linear filter \href{tseries/llf}{\texttt{llf}}.
\item
  \texttt{\textasciitilde{}Range} {[} numeric \textbar{} char \textbar{}
  \emph{\texttt{@all}} {]} - Date range on which the input data will be
  filtered; \texttt{Range} can be \texttt{@all}, \texttt{Inf},
  \texttt{{[}startdata,Inf{]}}, or \texttt{{[}-Inf,enddate{]}}; if
  omitted, \texttt{@all} (i.e.~the entire available range of the input
  series) is used.
\end{itemize}

\paragraph{Output arguments}

\begin{itemize}
\item
  \texttt{T} {[} tseries {]} - Lower-frequency (trend) component.
\item
  \texttt{C} {[} tseries {]} - Higher-frequency (cyclical) component.
\item
  \texttt{CutOff} {[} numeric {]} - Cut-off periodicity; periodicities
  above the cut-off are attributed to trends, periodicities below the
  cut-off are attributed to gaps.
\item
  \texttt{Lambda} {[} numeric {]} - Smoothing parameter actually used;
  this output argument is useful when the option
  \texttt{\textquotesingle{}CutOff=\textquotesingle{}} is used instead
  of \texttt{\textquotesingle{}Lambda=\textquotesingle{}}.
\end{itemize}

\paragraph{Options}

\begin{itemize}
\item
  \texttt{\textquotesingle{}CutOff=\textquotesingle{}} {[} numeric
  \textbar{} \emph{empty} {]} - Cut-off periodicity in periods
  (depending on the time series frequency); this option can be specified
  instead of \texttt{\textquotesingle{}Lambda=\textquotesingle{}}; the
  smoothing parameter will be then determined based on the cut-off
  periodicity.
\item
  \texttt{\textquotesingle{}CutOffYear=\textquotesingle{}} {[} numeric
  \textbar{} \emph{empty} {]} - Cut-off periodicity in years; this
  option can be specified instead of
  \texttt{\textquotesingle{}Lambda=\textquotesingle{}}; the smoothing
  parameter will be then determined based on the cut-off periodicity.
\end{itemize}

\texttt{\textquotesingle{}infoSet=\textquotesingle{}} {[} \texttt{1}
\textbar{} \emph{\texttt{2}} {]} - Information set assumption used in
the filter: \texttt{1} runs a one-sided filter, \texttt{2} runs a
two-sided filter.

\begin{itemize}
\item
  \texttt{\textquotesingle{}Lambda=\textquotesingle{}} {[} numeric
  \textbar{} \emph{\texttt{@auto}} {]} - Smoothing parameter; needs to
  be specified for tseries objects with indeterminate frequency. See
  Description for default values.
\item
  \texttt{\textquotesingle{}level=\textquotesingle{}} {[} tseries {]} -
  Time series with soft and hard tunes on the level of the trend.
\item
  \texttt{\textquotesingle{}change=\textquotesingle{}} {[} tseries {]} -
  Time series with soft and hard tunes on the change in the trend.
\item
  \texttt{\textquotesingle{}log=\textquotesingle{}} {[} \texttt{true}
  \textbar{} \emph{\texttt{false}} {]} - Logarithmise the data before
  filtering, de-logarithmise afterwards.
\end{itemize}

\paragraph{Description}

\subparagraph{Default smoothing
parameters}

If the user does not specify the smoothing parameter using the
\texttt{\textquotesingle{}lambda=\textquotesingle{}} option (or
reassigns the default \texttt{@auto}), a default value is used. The
default value is based on common practice and can be calculated using
the date frequency of the input time series as
\(\lambda = (10 \cdot f)^n\), where \(f\) is the frequency (yearly=1,
half-yearly=2, quarterly=4, bi-monthly=6, monthly=12), and \(n\) is the
order of the filter, determined by the input parameter \texttt{Order}.

\paragraph{Example}


